﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Text;
using System.Windows.Forms;
using System.IO;
using CrystalDecisions.CrystalReports.Engine;

namespace FlowCard
{
    public partial class Form1 : Form
    {
        SQLTools sqt;

        string strSelectACard = "select top 100 gd001 工单号,gd002 开卡日期,gd004 开卡人,gd007 型号规格,gd034 批号,gd010 开卡数量,gd030 执行标准,gd036 备注,gd031 质量等级,aka002 型号,aka003 尺寸,aka004 特性,aka005 电压,aka006 容量,aka007 精度,aka008 印叠机型,aka009 排粘曲线,aka010 引出端形式,aka011 瓷膜批号,aka012 内浆批号,aka013 端浆批号,aka014 丝网代号,aka015 印叠层数,aka016 瓷料名称,aka019 膜厚,htb032 产品单项备注 from gd_table left join htb_table on htb001=gd014 and htb002=gd015 left join praka_table on aka001=gd001 where gd025='A'";
        string strSelectBCard = "select top 100 gd001 工单号,gd002 开卡日期,gd004 开卡人,gd007 型号规格,gd034 B卡号,dbo.GetChipSN (a.gd001) A卡号,ISNULL(jhb024,'') 合同号,jhb009 交货日期,gd035 合同数量,gd010 开卡数量,gd031 质量等级,ycl021 容量,ycl022 精度,ycl025 引出端形式,gd030 执行标准,gd036 备注,dbo.IsWG (dbo.GetChipSN(a.gd001)) 内配芯片,dbo.IsWG (gd034) 内配B卡,htb032 产品单项备注 from gd_table a left join htb_table on htb001=a.gd014 and htb002=a.gd015 left join ycl_table on ycl001=a.gd007 left join scjhb_table on jhb001=gd027 and jhb002=gd028 where gd020='Y' and gd025='B'";
        string strSelectCCard = "select top 100 gd001 工单号,gd002 开卡日期,gd004 开卡人,gd007 型号规格,gd034 C卡号,(select top 1 gd034 from gd_table b where b.gd001 =a.gd026) B卡号,(select top 1 gd034 from gd_table b where b.gd001 =dbo.GetChipNo (a.gd001)) A卡号,gd035 合同数量,gd010 开卡数量,gd031 质量等级,ycl021 容量,ycl022 精度,gd030 执行标准,gd036 备注,htb032 产品单项备注 from gd_table a left join htb_table on htb001=a.gd014 and htb002=a.gd015 left join ycl_table on ycl001=a.gd007 where gd020='Y' and gd025='C'";
        string strUpdatePrintMark = "update gd_table set CardPrinted=@打印标记 where gd001='@GDNo'";
        string strSelectCardExist = "select * from gd_table a,(select gd001 工单号,gd034 批号,gd025 工单类型 from gd_table where gd001='@GDNo') b where a.gd001<>b.工单号 and (a.gd034=b.批号 or a.gd034 like b.批号+'%') and a.gd025=b.工单类型 and a.gd020='Y'";
        string strIsWG = "select dbo.IsWG('@SN')";

        string strUserName;
        string strDepartmentID;

        public Form1(string strTmpUserName,string strTmpDepartmentID)
        {
            InitializeComponent();
            strUserName = strTmpUserName;
            strDepartmentID = strTmpDepartmentID;
            this.Text = "流转卡打印工具 - " + strUserName;
            //switch (strDepartmentID)
            //{
            //    case "005":
            //    case "007":
            //        rbtnACard2.Checked = true;
            //        rbtnBCard2.Enabled = true ;
            //        rbtnCCard2.Enabled = false;
            //        break;
            //    case "012":
            //        rbtnBCard2.Checked = true;
            //        rbtnACard2.Enabled = false;
            //        rbtnCCard2.Enabled = false;
            //        break;
            //}
            //if (strUserName.Equals("oulihui"))
            //{
            //    rbtnBCard2.Checked = true;
            //    rbtnBCard2.Enabled = true;
            //}
        }

        #region 事件
        private void Form1_Load(object sender, EventArgs e)
        {
            sqt = new SQLTools();
            rbtnACard2.Checked = true;
            //rbtnACard2_CheckedChanged(this, new EventArgs());
        }

        private void ACard_CheckedChanged(object sender, EventArgs e)
        {
            if (rbtnACard.Checked) {
                rbtnBCard.Checked = false;
                rbtnCCard.Checked = false;
                rbtnOthers.Checked = false;
                lstCardType.Items.Clear();
                lstCardType.Items.Add("宇航级-片式MLCC生产流转卡");
                lstCardType.Items.Add("宇航级-引线MLCC生产流转卡");
                lstCardType.Items.Add("国军标-MLCC生产流转卡");
                lstCardType.Items.Add("国军标-引线MLCC生产流转卡");
                lstCardType.Items.Add("MLCC生产流转卡");
            }
        }

        private void BCard_CheckedChanged(object sender, EventArgs e)
        {
            if (rbtnBCard.Checked)
            {
                rbtnACard.Checked = false;
                rbtnCCard.Checked = false;
                rbtnOthers.Checked = false;
                lstCardType.Items.Clear();
                lstCardType.Items.Add("宇航级-片式MLCC生产流转卡");
                lstCardType.Items.Add("宇航级-引线MLCC生产流转卡");
                lstCardType.Items.Add("国军标-片式MLCC生产流转卡");
                lstCardType.Items.Add("国军标-引线MLCC生产流转卡");
                lstCardType.Items.Add("片式MLCC生产流转卡");
                lstCardType.Items.Add("引线MLCC生产流转卡");
            }
        }

        private void CCard_CheckedChanged(object sender, EventArgs e)
        {
            if (rbtnCCard.Checked)
            {
                rbtnACard.Checked = false;
                rbtnBCard.Checked = false;
                rbtnOthers.Checked = false;
                lstCardType.Items.Clear();
                lstCardType.Items.Add("引线MLCC生产流转卡");                
            }
        }

        private void others_CheckedChanged(object sender, EventArgs e)
        {
            if (rbtnOthers.Checked)
            {
                rbtnACard.Checked = false;
                rbtnBCard.Checked = false;
                rbtnCCard.Checked = false;
                lstCardType.Items.Clear();
                lstCardType.Items.Add("浆料配制/流延-生产流转卡");
            }
        }

        private void rbtnACard2_CheckedChanged(object sender, EventArgs e)
        {
            if (rbtnACard2.Checked)
            {
                rbtnBCard2.Checked = false;
                rbtnCCard2.Checked = false;
                rbtnOthers2.Checked = false;
                iniComboBox();
            }
        }

        private void rbtnBCard2_CheckedChanged(object sender, EventArgs e)
        {
            if (rbtnBCard2.Checked)
            {
                rbtnACard2.Checked = false;
                rbtnCCard2.Checked = false;
                rbtnOthers2.Checked = false;
                iniComboBox();
            }
        }

        private void rbtnCCard2_CheckedChanged(object sender, EventArgs e)
        {
            if (rbtnCCard2.Checked)
            {
                rbtnACard2.Checked = false;
                rbtnBCard2.Checked = false;
                rbtnOthers2.Checked = false;
                iniComboBox();
            }
        }

        private void rbtnOthers2_CheckedChanged(object sender, EventArgs e)
        {
            if (rbtnOthers2.Checked)
            {
                rbtnACard2.Checked = false;
                rbtnBCard2.Checked = false;
                rbtnCCard2.Checked = false;
                iniComboBox();
            }
        }

        private void rbtnManual_CheckedChanged(object sender, EventArgs e)
        {
            gbManual.Enabled = rbtnManual.Checked;
        }

        private void rbtnAutoMode_CheckedChanged(object sender, EventArgs e)
        {
            gbAutoMode.Enabled = rbtnAutoMode.Checked;
        }

        private void btnQuery_Click(object sender, EventArgs e)
        {
            string strTmpSelectString = string.Empty;
            if (rbtnACard2.Checked)
            {
                strTmpSelectString = strSelectACard+" and (gd005='" + strDepartmentID + "' or gd004='" + strUserName + "' or gd005='005')";
                pACard.Visible = true;
                pBCard.Visible = false;
                pCCard.Visible = false;
            }
            if (rbtnBCard2.Checked)
            {
                if (strUserName .Equals ( "系统管理员"))
                {
                    strTmpSelectString = strSelectBCard;
                }
                else if (strDepartmentID.Equals("012"))
                {
                    strTmpSelectString = strSelectBCard + " and (gd005='" + strDepartmentID + "' or gd005='005')";
                }
                else 
                {
                    strTmpSelectString = strSelectBCard + " and (gd005='" + strDepartmentID + "' or gd004='"+strUserName +"')";
                }
                pACard.Visible = false ;
                pBCard.Visible = true ;
                pCCard.Visible = false;
            }
            if (rbtnCCard2.Checked)
            {
                strTmpSelectString = strSelectCCard + " and (gd005='" + strDepartmentID + "' or gd004='" + strUserName + "')";
                pACard.Visible = false ;
                pBCard.Visible = false;
                pCCard.Visible = true ;
            }
            if (chkQueryAlreadyPrinted.Checked)
            {
                strTmpSelectString += " and CardPrinted=1";
            }
            else
            {
                strTmpSelectString += " and CardPrinted=0";
            }
            if (!txtKeyWord.Text.Trim().Equals(string.Empty))
            {
                strTmpSelectString += " and (gd001 like '" + txtKeyWord.Text.Trim() + "' or gd034 like '" + txtKeyWord.Text.Trim() + "')";
            }
            if (!txtOperator.Text.Trim().Equals(string.Empty))
            {
                strTmpSelectString += " and (gd003 ='" + txtOperator.Text.Trim() + "' or gd004 ='"+txtOperator .Text .Trim ()+"')";
            }
            strTmpSelectString += " order by gd001 desc";
            dgv1.DataSource = sqt.GetDataTable(strTmpSelectString);
            dgv1.AutoResizeColumns();
        }

        private void dgv1_CurrentCellChanged(object sender, EventArgs e)
        {
            if (dgv1.CurrentRow != null&&rbtnAutoMode .Checked )
            {
                if (rbtnACard2.Checked)         //当选择的是A卡
                {
                    txtGDNo_a.Text = GetString(dgv1.CurrentRow.Cells["工单号"].Value);
                    txtClass_a.Text = GetString(dgv1.CurrentRow.Cells["质量等级"].Value);
                    if (txtClass_a.Text.Trim().Equals(string.Empty))
                    {
                        string strTmpXhgg = GetString(dgv1.CurrentRow.Cells["型号规格"].Value);
                        if (strTmpXhgg.Contains("-"))
                        {
                            txtClass_a .Text  = strTmpXhgg.Substring(0, strTmpXhgg.IndexOf('-'));
                        }
                    }
                    txtModel_a.Text = GetString(dgv1.CurrentRow.Cells["型号"].Value);
                    txtSize_a.Text = GetString(dgv1.CurrentRow.Cells["尺寸"].Value);
                    txtSpecial_a .Text =GetString(dgv1.CurrentRow.Cells["特性"].Value);
                    txtVoltage_a .Text =GetString(dgv1.CurrentRow.Cells["电压"].Value);
                    txtCapacity_a .Text =GetString(dgv1.CurrentRow.Cells["容量"].Value);
                    txtAcc_a .Text =GetString(dgv1.CurrentRow.Cells["精度"].Value);
                    txtTerminal_a.Text = GetString(dgv1.CurrentRow.Cells["引出端形式"].Value);
                    txtSN_a.Text = GetString(dgv1.CurrentRow.Cells["批号"].Value);
                    txtKksl_a.Clear();      //开卡数量默认手工填写
                    txtZxbz_a.Text = GetString(dgv1.CurrentRow.Cells["执行标准"].Value);
                    txtClph.Text = GetString(dgv1.CurrentRow.Cells["瓷料名称"].Value);
                    txtCmhd.Text = GetString(dgv1.CurrentRow.Cells["膜厚"].Value);
                    txtYdsb.Text = GetString(dgv1.CurrentRow.Cells["印叠机型"].Value);
                    txtNdjph.Text = GetString(dgv1.CurrentRow.Cells["内浆批号"].Value);
                    txtDdjph.Text = GetString(dgv1.CurrentRow.Cells["端浆批号"].Value);
                    txtDc.Clear ();
                    txtSwdh.Text =GetString(dgv1.CurrentRow.Cells["丝网代号"].Value);
                    txtCpdxbz_a .Text = GetString(dgv1.CurrentRow.Cells["产品单项备注"].Value);
                    //select gd001 工单号,gd002 开卡日期,gd007 型号规格,gd034 批号,gd010 开卡数量
                    //gd030 执行标准,gd036 备注,gd031 质量等级,aka002 型号,aka003 尺寸,aka004 特性
                    //aka005 电压,aka006 容量,aka007 精度,aka008 印叠机型,aka009 排粘曲线,aka010 引出端形式
                    //aka011 瓷膜批号,aka012 内浆批号,aka013 端浆批号,aka014 丝网代号,aka015 印叠层数,aka016 瓷料名称,aka019 膜厚 
                    txtNdjhd.Clear ();
                    txtNdjcwl.Clear ();
                    string strTmpYdcs = GetString(dgv1.CurrentRow.Cells["印叠层数"].Value);
                    if (strTmpYdcs.Contains("/"))
                    {
                        txtYdcs.Text = strTmpYdcs.Split('/').GetValue(0).ToString();
                        txtHpcs.Text = strTmpYdcs.Split('/').GetValue(1).ToString();
                    }
                    else
                    {
                        txtYdcs.Text = strTmpYdcs;
                        txtHpcs.Clear();
                    }
                    txtBz_a.Text = GetString(dgv1.CurrentRow.Cells["备注"].Value); 
                    txtMark_a.Clear ();
                }
                if (rbtnBCard2.Checked)        //当选择的是B卡
                {
                    txtGDNo_b.Text = GetString(dgv1.CurrentRow.Cells["工单号"].Value);
                    txtModel_b.Text = GetString(dgv1.CurrentRow.Cells["型号规格"].Value);
                    txtClass_b.Text = GetString(dgv1.CurrentRow.Cells["质量等级"].Value);
                    if (txtClass_b.Text.Trim().Equals(string.Empty))
                    {
                        string strTmpXhgg = GetString(dgv1.CurrentRow.Cells["型号规格"].Value);
                        if (strTmpXhgg.Contains("SAST-GJB-"))
                        {
                            txtClass_b.Tag = "SAST-GJB";
                            txtClass_b.Text = "SAST+国军标";
                        }
                        else if (strTmpXhgg.Contains("SAST-G-"))
                        {
                            txtClass_b.Tag = "SAST-G";
                            txtClass_b.Text = "SAST+G";
                        }
                        else if (strTmpXhgg.Contains("SAST-QJ-"))
                        {
                            txtClass_b.Tag = "SAST-QJ";
                            txtClass_b.Text = "SAST+QJ";
                        }
                        else if (strTmpXhgg.Contains("-"))
                        {
                            txtClass_b.Text = strTmpXhgg.Substring(0, strTmpXhgg.IndexOf('-'));
                        }
                    }
                    txtSNB_b.Text = GetString(dgv1.CurrentRow.Cells["B卡号"].Value);
                    txtSNA_b.Text = GetString(dgv1.CurrentRow.Cells["A卡号"].Value);
                    txtHtsl_b.Text = GetString(dgv1.CurrentRow.Cells["合同数量"].Value).Replace(".00", string.Empty);
                    txtKksl_b.Text = GetString(dgv1.CurrentRow.Cells["开卡数量"].Value).Replace(".00", string.Empty);
                    txtZxbz_b.Text = GetString(dgv1.CurrentRow.Cells["执行标准"].Value); 
                    txtCapacity_b.Text = GetString(dgv1.CurrentRow.Cells["容量"].Value);
                    txtAcc_b.Text = GetString(dgv1.CurrentRow.Cells["精度"].Value);
                    txtTerminal_b.Text = GetString(dgv1.CurrentRow.Cells["引出端形式"].Value);
                    txtBz_b.Text = GetString(dgv1.CurrentRow.Cells["备注"].Value);
                    txtCpdxbz_b.Text = GetString(dgv1.CurrentRow.Cells["产品单项备注"].Value);
                    txtMark_b.Clear();
                    chkHK_b.Checked = false;
                    chkJJ_b.Checked = false;
                    chkXQ_b.Checked = false;
                    chkBy_b.Checked = false;
                    chkSjfhyq_b.Checked = false;
                    chkDPA_b.Checked = false;
                    chkFh_b.Checked = false;
                    chkTcc_b.Checked = false;
                    //如果质量等级为J、M、G，则想勾选DPA合格
                    if (txtClass_b.Text.Trim().Equals("M") ||
                        txtClass_b.Text.Trim().Equals("J") ||
                        txtClass_b.Text.Trim().Equals("G")||
                        txtClass_b.Text.Trim().Equals("C"))
                    {
                        chkDPA_b.Checked = true;
                    }
                    else
                    {
                        chkFh_b.Checked = true;
                    }
                    //如果产品为内配产品，则需勾选TCC测试
                    if (GetInt(sqt.DoCmdScalarData(strIsWG.Replace("@SN", txtSNB_b.Text.Trim()))) == 1)
                    {
                        chkTcc_b.Checked = true;
                    }
                    txtHth_b.Text = GetString(dgv1.CurrentRow.Cells["合同号"].Value);
                    txtJhrq_b.Text = GetString(dgv1.CurrentRow.Cells["交货日期"].Value);
                }
                if (rbtnCCard2.Checked)        //当选择的是C卡
                {
                    txtGDNo_c.Text = GetString(dgv1.CurrentRow.Cells["工单号"].Value);
                    txtModel_c.Text = GetString(dgv1.CurrentRow.Cells["型号规格"].Value);
                    txtClass_c.Text = GetString(dgv1.CurrentRow.Cells["质量等级"].Value);
                    if (txtClass_c.Text.Trim().Equals(string.Empty))
                    {
                        string strTmpXhgg = GetString(dgv1.CurrentRow.Cells["型号规格"].Value);
                        if (strTmpXhgg.Contains("-"))
                        {
                            txtClass_c.Text = strTmpXhgg.Substring(0, strTmpXhgg.IndexOf('-'));
                        }
                    }
                    txtKksl_c.Text = GetString(dgv1.CurrentRow.Cells["开卡数量"].Value).Replace(".00", string.Empty);
                    txtHtsl_c.Text = GetString(dgv1.CurrentRow.Cells["合同数量"].Value).Replace(".00", string.Empty);
                    txtSNC.Text = GetString(dgv1.CurrentRow.Cells["C卡号"].Value);
                    txtSNB_c.Text = GetString(dgv1.CurrentRow.Cells["B卡号"].Value);
                    txtSNA_c.Text = GetString(dgv1.CurrentRow.Cells["A卡号"].Value);
                    txtCapacity_c.Text = GetString(dgv1.CurrentRow.Cells["容量"].Value);
                    txtAcc_c.Text = GetString(dgv1.CurrentRow.Cells["精度"].Value);
                    txtZxbz_c.Text = GetString(dgv1.CurrentRow.Cells["执行标准"].Value);
                    txtBz_c.Text = GetString(dgv1.CurrentRow.Cells["备注"].Value);
                    txtCpdxbz_c.Text = GetString(dgv1.CurrentRow.Cells["产品单项备注"].Value);
                    txtMark_c.Clear();
                }
            }
        }

        private void chkTemplate_CheckedChanged(object sender, EventArgs e)
        {
            cmbTemplates.Enabled = chkTemplate.Checked;
        }

        private void btnPrint_Click(object sender, EventArgs e)
        {
            string strCardType = string.Empty;
            string strClass = string.Empty;
            string strProductType = string.Empty;
            string strGDNo = string.Empty;
            if (rbtnManual.Checked)
            {
                
            }
            else
            {
                if (rbtnACard2.Checked)
                {
                    strCardType = "A";
                    strClass = txtClass_a.Text.Trim().ToUpper();
                    if ((txtModel_a.Text.Contains("C41") ||
                        txtModel_a.Text.Contains("T41") ||
                        txtModel_a.Text.Contains("K41") ||
                        txtModel_a.Text.Contains("C039") ||
                        txtModel_a.Text.Contains("CT48-")))
                    {
                        strProductType = "片式";
                    }
                    else
                    {
                        //此处欠处理C039、C040、C041等型号产品代码
                        strProductType = "引线";
                    }
                    strGDNo = txtGDNo_a.Text;
                    #region 检查丝网代号与内电极错位量是否对应
                    if (!sqt.RecordExist("select 丝网代号 from Swdh where 丝网代号='" + txtSwdh.Text.Trim() + "' and 内电极错位量='" + txtNdjcwl.Text.Trim() + "'"))
                    {
                        if (MessageBox.Show("当前丝网代号与内电极错位量对应信息与数据库中信息不符，请检查后确认是否继续操作？", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel)
                        {
                            return;
                        }
                    }
                    #endregion
                    #region 检查是否发36所J等级产品，如果是，检查A卡是否是J或M等级产品，如果是，则不允许打印流转卡
                    string strTmpCheck36 = "select hta003 客户编码,htb003 订货型号规格,gd007 A卡型号规格 from hta_table,htb_table,gd_table where gd014=hta001 and gd015=htb002 and gd001='" + txtGDNo_a.Text + "'";
                    DataTable tmpdt36 = sqt.GetDataTable(strTmpCheck36);
                    if (tmpdt36.Rows.Count > 0 &&
                        GetString(tmpdt36.Rows[0]["客户编码"]).StartsWith("08-36") &&
                        GetString(tmpdt36.Rows[0]["订货型号规格"]).StartsWith("J-") &&
                        (GetString(tmpdt36.Rows[0]["A卡型号规格"]).StartsWith("J-") ||
                        GetString(tmpdt36.Rows[0]["A卡型号规格"]).StartsWith("M-"))
                        )
                    {
                        MessageBox.Show("36所J等级产品必须使用G及以上等级产品替代发放，请检查后重新操作！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    #endregion
                }
                if (rbtnBCard2.Checked)
                {
                    strGDNo = txtGDNo_b.Text;
                    if (!(GetString(dgv1.CurrentRow.Cells["内配芯片"].Value).Equals(string.Empty) || GetString(dgv1.CurrentRow.Cells["内配芯片"].Value).Equals("0")))
                    {
                        if (!dgv1.CurrentRow.Cells["内配B卡"].Value.Equals(dgv1.CurrentRow.Cells["内配芯片"].Value))
                        {
                            if(MessageBox.Show("本卡芯片号类型与B卡号类型不一致，请检查！点击确定继续操作！", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information)==DialogResult.Cancel);
                                return;
                        }
                    }
                    #region 如果执行标准为Q/RQ140-2004，Q/RQ141-2004，Q/RQ142-2004，Q/RQ143-2004，按条件检查是否符合开卡条件
                    if (txtZxbz_b.Text.Contains("140-2004") ||
                        txtZxbz_b.Text.Contains("141-2004") ||
                        txtZxbz_b.Text.Contains("142-2004") ||
                        txtZxbz_b.Text.Contains("143-2004"))
                    {
                        //开卡工序如果是半成品库，3月16日后开的B卡不允许使用老标准
                        //如果投料工序是B卡发料，且没有自检出库，则判定为半成品库开卡
                        bool bZjck = false;     //是否自检出库
                        //检查工单是否由自检出库单生成
                        string strTmpCheckZjck = "select gxck001 from gxck_table where gxck016='Y' and gxck053=2 and gxck028='" + strGDNo + "'";
                        bZjck = sqt.RecordExist(strTmpCheckZjck);
                        bool bBkfl = false;     //是否B卡发料投料
                        //检查开卡工序是否B卡发料
                        string strTmpCheckBfl = "select gd029 from gd_table where gd001='" + strGDNo + "'";
                        bBkfl = sqt.RecordExist(strTmpCheckBfl);
                        //检查开卡日期是否2018年3月16日后
                        string strTmpGetOpenDate = "select case when (gd002>='20180316') then 1 else 0 end 开卡日期 from gd_table where gd001='" + strGDNo + "'";
                        bool bOpenDate = GetBoolean(sqt.DoCmdScalarData(strTmpGetOpenDate));
                        if (bOpenDate && (!bZjck) && bBkfl)
                        {
                            if (MessageBox.Show("2018年3月15日接马千通知，即日起停止发放Q/RQ140-2004，Q/RQ141-2004，Q/RQ142-2004，Q/RQ143-2004标准，请检查后重新操作。", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel)
                            {
                                return;
                            }
                        }
                    }
                    #endregion
                    #region 如果执行标准为CAST029-2006/030-2006/031-2006、045C，检查工单开卡日期，如果开卡日期晚于2017年8月10日，则提示错误，终止操作
                    if (txtZxbz_b.Text.Contains ("029-2006")||
                        txtZxbz_b.Text.Contains("030-2006") ||
                        txtZxbz_b.Text.Contains("031-2006") ||
                        txtZxbz_b.Text.Contains("045C"))
                    {
                        string strTmpGetOpenDate = "select case when (gd002>='20170810') then 1 else 0 end 开卡日期 from gd_table where gd001='" + strGDNo + "'";
                        bool bOpenDate = GetBoolean(sqt.DoCmdScalarData(strTmpGetOpenDate));
                        if (bOpenDate )
                        {
                            if (MessageBox.Show ("2017年8月10日的CC产品只允许执行带A的新标准，请检查确定！点击确定继续打印，点击取消可取消打印！","提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Question)==DialogResult.Cancel)
                            {
                                return;
                            }
                        }
                    }
                    #endregion
                    #region 检查是否发704 G-CT4L-3-2C1-100V-103K产品，如果是，检查芯片号是否是1812产品，如果不符，弹出提示，停止操作
                    if (txtModel_b.Equals("G-CT4L-3-2C1-100V-103K"))
                    {
                        string strTmpCheck704 = "select a.gd007 芯片型号 from hta_table ,gd_table b,gd_table a where b.gd014=hta001 and a.gd001=dbo.GetChipNo (b.gd001) and hta003 like '704%' and b.gd001='" + txtGDNo_b.Text + "'";
                        DataTable tmpdt704 = sqt.GetDataTable(strTmpCheck704);
                        if (tmpdt704.Rows.Count > 0)
                        {
                            if (!GetString(tmpdt704.Rows[0]["芯片型号"]).Contains("1812"))
                            {
                                MessageBox.Show("704所G-CT4L-3-2C1-100V-103K产品必须用1812芯片发B卡，请检查后重新操作！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                return;
                            }
                        }
                    }
                    #endregion
                    #region 检查是否发36所J等级产品，如果是，检查B卡是否是J或M等级产品，如果是，则不允许打印流转卡
                    string strTmpCheck36 = "select hta003 客户编码,htb003 订货型号规格,gd007 B卡型号规格 from hta_table,htb_table,gd_table where gd014=hta001 and gd015=htb002 and gd001='" + txtGDNo_b.Text + "'";
                    DataTable tmpdt36 = sqt.GetDataTable(strTmpCheck36);
                    if (tmpdt36.Rows.Count > 0 &&
                        GetString(tmpdt36.Rows[0]["客户编码"]).StartsWith("08-36") &&
                        GetString(tmpdt36.Rows[0]["订货型号规格"]).StartsWith("J-") &&
                        (GetString(tmpdt36.Rows[0]["B卡型号规格"]).StartsWith("J-") ||
                        GetString(tmpdt36.Rows[0]["B卡型号规格"]).StartsWith("M-"))
                        )
                    {
                        MessageBox.Show("36所J等级产品必须使用G及以上等级产品替代发放，请检查后重新操作！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    #endregion
                    strCardType = "B";
                    strClass = txtClass_b.Text.Trim().ToUpper();
                    if((txtModel_b.Text.Contains("C41") ||
                        txtModel_b.Text.Contains("T41") ||
                        txtModel_b.Text.Contains("K41") ||
                        txtModel_b.Text.Contains("C039") ||
                        txtModel_b.Text.Contains("CT48-")))
                    {
                        strProductType = "片式";
                    }
                    else
                    {
                        //此处欠处理C039、C040、C041等型号产品代码
                        strProductType = "引线";
                    }
                    if (strClass.Equals("CC"))
                    {
                        if (strProductType.Equals("片式") && txtSNB_b.Text.Trim().Length != 10)
                        {
                            MessageBox.Show("卡号与CC产品流转卡号规则不符，请检查后继续操作！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        if (strProductType.Equals("引线") && txtSNB_b.Text.Trim().Length != 9)
                        {
                            MessageBox.Show("卡号与CC产品流转卡号规则不符，请检查后继续操作！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                    }
                    strGDNo = txtGDNo_b.Text;
                }
                if (rbtnCCard2.Checked)
                {
                    strCardType = "C";
                    strGDNo = txtGDNo_c.Text;
                }
                if (rbtnOthers2.Checked)
                {
                    return;
                }
            }
            if (!strGDNo.Equals(string.Empty))
            {
                if (sqt.RecordExist(strSelectCardExist.Replace("@GDNo", strGDNo)))
                {
                    if (MessageBox .Show ("已存在相同卡号的其他流转卡，请检查确认是否继续打印！","提示",MessageBoxButtons .OKCancel ,MessageBoxIcon .Warning )==DialogResult .Cancel )
                    {
                        return ;
                    }
                }
            }
            DataTable tmpdt = GetReportData(strCardType);
            string strReportPath = Application.StartupPath + "\\Cards\\";
            string strReportFileName = string.Empty;
            switch (strCardType)
            {
                case "A":
                    strReportFileName = strReportPath + "MLCC生产流转卡A卡.rpt";
                    if (strClass.Equals("GJB"))
                    {
                        if (strProductType.Equals("片式"))
                        {
                            strReportFileName = strReportPath + "国军标片式MLCC生产流转卡A卡.rpt";
                        }
                        else
                        {
                            strReportFileName = strReportPath + "国军标引线MLCC生产流转卡A卡.rpt";
                        }
                    }
                    if (strClass.Equals("TJ"))
                    {
                        if (strProductType.Equals("片式"))
                        {
                            strReportFileName = strReportPath + "TJ片式MLCC生产流转卡A卡.rpt";
                        }
                        else
                        {
                            strReportFileName = strReportPath + "TJ引线MLCC生产流转卡A卡.rpt";
                        }
                    }
                    if (strClass.Contains("YH") || strClass.Contains("宇航"))
                    {
                        if (strProductType.Equals("片式"))
                        {
                            strReportFileName = strReportPath + "宇航级片式MLCC生产流转卡A卡.rpt";
                        }
                        else
                        {
                            strReportFileName = strReportPath + "宇航级引线MLCC生产流转卡A卡.rpt";
                        }
                    }
                    break;
                case "B":
                    if (strProductType.Equals("片式"))
                    {
                        strReportFileName = strReportPath + "片式MLCC生产流转卡B卡.rpt";
                    }
                    else
                    {
                        strReportFileName = strReportPath + "引线MLCC生产流转卡B卡.rpt";
                    }
                    if (strClass.Equals("GJB"))
                    {
                        if (strProductType.Equals("片式"))
                        {
                            strReportFileName = strReportPath + "国军标片式MLCC生产流转卡B卡.rpt";
                        }
                        else
                        {
                            strReportFileName = strReportPath + "国军标引线MLCC生产流转卡B卡.rpt";
                        }
                    }
                    if (strClass.Equals("TJ"))
                    {
                        if (strProductType.Equals("片式"))
                        {
                            strReportFileName = strReportPath + "TJ片式MLCC生产流转卡B卡.rpt";
                        }
                        else
                        {
                            strReportFileName = strReportPath + "TJ引线MLCC生产流转卡B卡.rpt";
                        }
                    }
                    if (strClass.Contains("YH") || strClass.Contains("宇航"))
                    {
                        if (strProductType.Equals("片式"))
                        {
                            strReportFileName = strReportPath + "宇航级片式MLCC生产流转卡B卡.rpt";
                        }
                        else
                        {
                            strReportFileName = strReportPath + "宇航级引线MLCC生产流转卡B卡.rpt";
                        }
                    }
                    break;
                case "C":
                    strReportFileName = strReportPath + "引线MLCC生产流转卡C卡.rpt";
                    break;
                default:
                    return;
                    break;
            }
            if (frmPreview.ShowForm(strUserName,strGDNo , tmpdt, strReportFileName, strCardType))
            {
                if (!strGDNo.Equals(string.Empty))
                {
                    sqt.DoCmdExecuteNonQuery(strUpdatePrintMark.Replace("@打印标记", "1")
                                                                                                            .Replace("@GDNo", strGDNo));
                }
                btnQuery_Click(this, new EventArgs());
            }
        }

        private void TextBox_Change(object sender, EventArgs e)
        {
            TextBox t = (TextBox)sender;
            if (t.Text.Trim().Equals(string.Empty))
            {
                t.BackColor = Color.Yellow;
            }
            else
            {
                t.BackColor = Color.White ;
            }
        }

        private void TextBox_Change2(object sender, EventArgs e)
        {
            TextBox t = (TextBox)sender;
            if (t.Text.Trim().Equals(string.Empty) || t.Text.Trim().Equals("0"))
            {
                t.BackColor = Color.Yellow;
            }
            else
            {
                t.BackColor = Color.White;
            }
        }

        private void btnQuerySNAssign_Click(object sender, EventArgs e)
        {
            frmSNQuery newFrmSNQuery = new frmSNQuery();
            newFrmSNQuery.Show();
        }

        private void 查看打印记录ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (dgv1.CurrentRow != null)
            {
                frmLogViewer newFrmLogViewer = new frmLogViewer(strUserName , GetString(dgv1.CurrentRow.Cells["工单号"].Value));
                newFrmLogViewer.ShowDialog();
            }
        }

        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }
        #endregion

        #region 方法
        #region 数据转换
        /// <summary>
        /// 将对象转换为字符串
        /// </summary>
        /// <param name="tmpobj">要转换的对象</param>
        /// <param name="strdefault">转换错误时的默认值</param>
        /// <returns>字符串结果</returns>
        public static string GetString(object tmpobj, string strdefault)
        {
            try
            {
                return tmpobj.ToString();
            }
            catch
            {
                return strdefault;
            }
        }

        /// <summary>
        /// 将对象转换为字符串
        /// </summary>
        /// <param name="tmpobj">要转换的对象（默认值为string.Empty）</param>
        /// <returns>字符串结果</returns>
        public static string GetString(object tmpobj)
        {
            return GetString(tmpobj, string.Empty);
        }

        /// <summary>
        /// 将对象转换为整型
        /// </summary>
        /// <param name="tmpobj">要转换的对象</param>
        /// <param name="idefault">转换错误时的默认值</param>
        /// <returns>整型结果</returns>
        public static int GetInt(object tmpobj, int idefault)
        {
            try
            {
                return Convert.ToInt32(tmpobj);
            }
            catch
            {
                return idefault;
            }
        }

        /// <summary>
        /// 将对象转换为整型
        /// </summary>
        /// <param name="tmpobj">要转换的对象（默认值为0）</param>
        /// <returns>整型结果</returns>
        public static int GetInt(object tmpobj)
        {
            return GetInt(tmpobj, 0);
        }

        /// <summary>
        /// 将对象转换为浮点数
        /// </summary>
        /// <param name="tmpobj">要转换的对象</param>
        /// <param name="ddefault">转换错误时的默认值</param>
        /// <returns>浮点结果</returns>
        public static double GetDouble(object tmpobj, double ddefault)
        {
            try
            {
                return Convert.ToDouble(tmpobj);
            }
            catch
            {
                return ddefault;
            }
        }

        /// <summary>
        /// 将对象转换为浮点数
        /// </summary>
        /// <param name="tmpobj">要转换的对象（默认值为0d）</param>
        /// <returns>浮点结果</returns>
        public static double GetDouble(object tmpobj)
        {
            return GetDouble(tmpobj, 0d);
        }

        /// <summary>
        /// 将对象转换为布尔型
        /// </summary>
        /// <param name="tmpobj">要转换的对象</param>
        /// <param name="bdefault">转换错误时的默认值</param>
        /// <returns>布尔结果</returns>
        public static bool GetBoolean(object tmpobj, bool bdefault)
        {
            try
            {
                return Convert.ToBoolean(tmpobj);
            }
            catch
            {
                return bdefault;
            }
        }

        /// <summary>
        /// 将对象转换为布尔型
        /// </summary>
        /// <param name="tmpobj">要转换的对象（默认值为false）</param>
        /// <returns>布尔结果</returns>
        public static bool GetBoolean(object tmpobj)
        {
            return GetBoolean(tmpobj, false);
        }

        private double CapactiyTranslate(string strC)
        {
            string strTmp = string.Empty;
            //如果容量中包含PF字样，如195PF±0.5PF或16500PFJ
            if (strC.Contains("PF"))
            {
                strTmp = strC.Substring(0, strC.IndexOf('P'));
                return GetDouble(strTmp);
            }
            //如果未包含PF字样，则一律按照三标法处理
            try
            {
                strTmp = strC.Substring(0, 3).ToUpper();
                if (strTmp.Contains("R"))
                {
                    return GetDouble(strTmp.Replace("R", "."));
                }
                else
                {
                    double iX = Convert.ToDouble(strTmp.Substring(0, 2));
                    double iY = Convert.ToDouble(strTmp.Substring(2, 1));
                    return iX * Math.Pow(10, iY);
                }
            }
            catch
            {
                return 0d;
            }
        }

        private double VoltageTranslate(string strTmpVoltage)
        {
            double r = 0d;
            if (strTmpVoltage.ToUpper().Contains("V"))
            {
                strTmpVoltage = strTmpVoltage.Replace("V", "");
            }
            if (strTmpVoltage.ToUpper().Contains("K"))
            {
                r = GetDouble(strTmpVoltage.Substring(0, strTmpVoltage.Length - 1)) * 1000;
            }
            else
            {
                r = GetDouble(strTmpVoltage);
            }
            return r;
        }
        #endregion

        private DataTable GetReportData(string strCardType)
        {
            DataTable tmpdt = new DataTable();
            tmpdt.TableName = "ReportData";
            switch (strCardType)
            {
                case "A":
                    tmpdt.Columns.Add("条形码", typeof(byte[]));
                    tmpdt.Columns.Add("质量等级");
                    tmpdt.Columns.Add("卡号");
                    tmpdt.Columns.Add("型号");
                    tmpdt.Columns.Add("尺寸");
                    tmpdt.Columns.Add("特性");
                    tmpdt.Columns.Add("电压");
                    tmpdt.Columns.Add("容量");
                    tmpdt.Columns.Add("精度");
                    tmpdt.Columns.Add("引出端形式");
                    tmpdt.Columns.Add("开卡数量");
                    tmpdt.Columns.Add("执行标准");
                    tmpdt.Columns.Add("瓷料牌号");
                    tmpdt.Columns.Add("瓷膜厚度");
                    tmpdt.Columns.Add("印叠设备");
                    tmpdt.Columns.Add("内电极牌号");
                    tmpdt.Columns.Add("端电极牌号");
                    tmpdt.Columns.Add("镀层");
                    tmpdt.Columns.Add("丝网代号");
                    tmpdt.Columns.Add("内电极厚度");
                    tmpdt.Columns.Add("内电极错位量");
                    tmpdt.Columns.Add("印叠层数");
                    tmpdt.Columns.Add("护片层数");
                    tmpdt.Columns.Add("备注");
                    tmpdt.Columns.Add("标志标识");
                    tmpdt.Columns.Add("备注标识");
                    tmpdt.Columns.Add("合同号");
                    tmpdt.Columns.Add("交货日期");
                    tmpdt.Columns.Add("开卡日期");
                    DataRow dr = tmpdt.NewRow();
                    Bitmap tmpb = BarCode39.GetCode39(txtGDNo_a.Text);
                    if (tmpb != null)
                    {
                        MemoryStream ms = new MemoryStream();
                        tmpb.Save(ms, ImageFormat.Bmp);
                        Byte[] bytes = ms.GetBuffer();
                        dr["条形码"] = bytes;
                        ms.Close();
                    }
                    dr["质量等级"] = txtClass_a.Text;
                    dr["卡号"] = txtSN_a.Text;
                    dr["型号"] = txtModel_a.Text;
                    dr["尺寸"] = txtSize_a.Text;
                    dr["特性"] = txtSpecial_a.Text;
                    dr["电压"] = txtVoltage_a.Text;
                    dr["容量"] = txtCapacity_a.Text;
                    dr["精度"] = txtAcc_a.Text;
                    dr["引出端形式"] = txtTerminal_a.Text;
                    dr["开卡数量"] = txtKksl_a.Text;
                    dr["执行标准"] = txtZxbz_a.Text;
                    dr["瓷料牌号"] = txtClph.Text;
                    dr["瓷膜厚度"] = txtCmhd.Text;
                    dr["印叠设备"] = txtYdsb.Text;
                    dr["内电极牌号"] = txtNdjph.Text;
                    dr["端电极牌号"] = txtDdjph.Text;
                    dr["镀层"] = txtDc.Text;
                    dr["丝网代号"] = txtSwdh.Text;
                    dr["内电极厚度"] = txtNdjhd.Text;
                    dr["内电极错位量"] = txtNdjcwl.Text;
                    dr["印叠层数"] = txtYdcs.Text;
                    dr["护片层数"] = txtHpcs.Text;
                    dr["备注"] = txtBz_a.Text + "  " + txtCpdxbz_a.Text;
                    dr["标志标识"] = txtMark_a.Text;
                    tmpdt.Rows.Add(dr);
                    break;
                case "B":
                    tmpdt.Columns.Add("条形码",typeof (byte []));
                    tmpdt.Columns.Add("质量等级");
                    tmpdt.Columns.Add("B卡号");
                    tmpdt.Columns.Add("合同数量");
                    tmpdt.Columns.Add("开卡数量");
                    tmpdt.Columns.Add("型号规格");
                    tmpdt.Columns.Add("容量");
                    tmpdt.Columns.Add("精度");
                    tmpdt.Columns.Add("引出端形式");
                    tmpdt.Columns.Add("A卡号");
                    tmpdt.Columns.Add("执行标准");
                    tmpdt.Columns.Add("备注");
                    tmpdt.Columns.Add("标志标识");
                    tmpdt.Columns.Add("备注标识");
                    tmpdt.Columns.Add("合同号");
                    tmpdt.Columns.Add("交货日期");
                    dr = tmpdt.NewRow();
                    tmpb = BarCode39.GetCode39(txtGDNo_b.Text);
                    if (tmpb !=null )
                    {
                        MemoryStream ms=new MemoryStream ();
                        tmpb.Save (ms,ImageFormat .Bmp );
                        Byte [] bytes= ms.GetBuffer ();
                        dr["条形码"] = bytes;
                        ms.Close();
                    }
                    switch (txtClass_b.Text.Trim())
                    {
                        case "M":
                            dr["质量等级"] = "工业级";
                            break;
                        case "C":
                            dr["质量等级"] = "按七专工艺生产";
                            break;
                        case "SAST-GJB":
                            dr["质量等级"] = "SAST+国军标";
                            break;
                        case "SAST-QJ":
                            dr["质量等级"] = "SAST+QJ";
                            break;
                        case "SAST-G":
                            dr["质量等级"] = "SAST+G";
                            break;
                        default:
                            dr["质量等级"] = txtClass_b.Text;
                            break;
                    }
                    dr["B卡号"]=txtSNB_b .Text ;
                    dr["合同数量"]=txtHtsl_b .Text ;
                    dr["开卡数量"]=txtKksl_b .Text ;
                    string strTmpModel = txtModel_b.Text.Trim();
                    if (strTmpModel.EndsWith("-Z") || strTmpModel.EndsWith("-M"))
                    {
                        dr["型号规格"] = strTmpModel.Substring(txtClass_b.Text.Trim().Length+1, strTmpModel.Length - txtClass_b.Text.Trim().Length - 2 - txtCapacity_b.Text.Trim().Length - txtAcc_b.Text.Trim().Length - 2);
                    }
                    else
                    {
                        dr["型号规格"] = strTmpModel.Substring(txtClass_b.Text.Trim().Length+1, strTmpModel.Length - txtClass_b.Text.Trim().Length - 2 - txtCapacity_b.Text.Trim().Length - txtAcc_b.Text.Trim().Length);
                    }
                    dr["容量"]=txtCapacity_b .Text ;
                    dr["精度"]=txtAcc_b .Text ;
                    dr["引出端形式"] = txtTerminal_b.Text;
                    dr["A卡号"]=txtSNA_b .Text ;
                    dr["执行标准"]=txtZxbz_b .Text ;
                    dr["备注"]=txtBz_b .Text + "  " + txtCpdxbz_b.Text;
                    //dr["标志标识"]=txtMark_b .Text ;
                    string strTmpMark = txtMark_b.Text;
                    if (chkHK_b.Checked)
                    {
                        strTmpMark += "        HK";
                    }
                    if (chkJJ_b.Checked)
                    {
                        strTmpMark += "        急件";
                    }
                    if (chkXQ_b.Checked)
                    {
                        strTmpMark += "        锡铅";
                    }
                    if (chkBy_b.Checked)
                    {
                        strTmpMark += "        钯银";
                    }
                    if (chkSjfhyq_b .Checked )
                    {
                        strTmpMark += "        设计符合要求";
                    }
                    string[] tmpp = strTmpModel.Split('-');
                    string strTmpClass = string.Empty;
                    string strTmpModel2 = string.Empty;
                    string strTmpSize = string.Empty;
                    string strTmpSpecial = string.Empty;
                    string strTmpVoltage = string.Empty;
                    string strTmpCapacity2 = string.Empty;
                    string strTmpTerminal = string.Empty;
                    bool bSplitModel = false;
                    if (tmpp.Length == 5)
                    {
                        if (tmpp[1].Contains("0"))
                        {
                            strTmpClass = tmpp[0];
                            strTmpModel2 = tmpp[1];
                            strTmpSize = string.Empty;
                            strTmpSpecial = tmpp[2];
                            strTmpVoltage = tmpp[3];
                            strTmpCapacity2 = tmpp[4];
                            strTmpTerminal = string.Empty;
                            bSplitModel = true;
                        }
                        else
                        {
                            strTmpClass = tmpp[0];
                            strTmpModel2 = tmpp[1];
                            strTmpSize = tmpp[2];
                            strTmpSpecial = string.Empty;
                            strTmpVoltage = tmpp[3];
                            strTmpCapacity2 = tmpp[4];
                            strTmpTerminal = string.Empty;
                            bSplitModel = true;
                        }
                    }
                    else if (tmpp.Length == 6)
                    {
                        strTmpClass = tmpp[0];
                        strTmpModel2 = tmpp[1];
                        strTmpSize = tmpp[2];
                        strTmpSpecial = tmpp[3];
                        strTmpVoltage = tmpp[4];
                        strTmpCapacity2 = tmpp[5];
                        strTmpTerminal = string.Empty;
                        bSplitModel = true;
                    }
                    else if (tmpp.Length == 7)
                    {
                        if (strTmpModel.StartsWith("SAST-G") ||
                            strTmpModel.StartsWith("SAST-QJ") ||
                            strTmpModel.StartsWith("SAST-GJB"))
                        {
                            strTmpClass = tmpp[0] + "-" + tmpp[1];
                            strTmpModel2 = tmpp[2];
                            strTmpSize = tmpp[3];
                            strTmpSpecial = tmpp[4];
                            strTmpVoltage = tmpp[5];
                            strTmpCapacity2 = tmpp[6];
                            strTmpTerminal = string.Empty;
                            bSplitModel = true;
                        }
                        else if (strTmpModel.Contains("C041"))
                        {
                            strTmpClass = tmpp[0];
                            strTmpModel2 = tmpp[1] + "-" + tmpp[2];
                            strTmpSize = tmpp[3];
                            strTmpSpecial = tmpp[4];
                            strTmpVoltage = tmpp[5];
                            strTmpCapacity2 = tmpp[6];
                            strTmpTerminal = string.Empty;
                            bSplitModel = true;
                        }
                        else if (strTmpModel.Contains("CT41P"))
                        {
                            strTmpClass = tmpp[0];
                            strTmpModel2 = tmpp[1] + "-" + tmpp[2];
                            strTmpSize = tmpp[3];
                            strTmpSpecial = tmpp[4];
                            strTmpVoltage = tmpp[5];
                            strTmpCapacity2 = tmpp[6];
                            strTmpTerminal = string.Empty;
                            bSplitModel = true;
                        }
                        else
                        {
                            strTmpClass = tmpp[0];
                            strTmpModel2 = tmpp[1];
                            strTmpSize = tmpp[2];
                            strTmpSpecial = tmpp[3];
                            strTmpVoltage = tmpp[4];
                            strTmpCapacity2 = tmpp[5];
                            strTmpTerminal = tmpp[6];
                            bSplitModel = true;
                        }
                    }
                    else if (tmpp.Length == 8)
                    {
                        strTmpClass = tmpp[0] + "-" + tmpp[1];
                        strTmpModel2 = tmpp[2];
                        strTmpSize = tmpp[3];
                        strTmpSpecial = tmpp[4];
                        strTmpVoltage = tmpp[5];
                        strTmpCapacity2 = tmpp[6];
                        strTmpTerminal = tmpp[7];
                        bSplitModel = true;
                    }
                    else
                    {
                        MessageBox.Show("识别产品型号时出现错误，获取加速筛选信息可能有误，操作将中断，请联系管理员。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        bSplitModel = false;
                    }
                    if (bSplitModel)
                    {
                        string str25UR1 = CheckJsSxVoltage(txtGDNo_b.Text, txtZxbz_b.Text.Trim(), strTmpClass, strTmpModel2, strTmpSize, strTmpVoltage, strTmpCapacity2, txtSNB_b.Text.Trim(), txtBz_b.Text.Trim());
                        string str25UR2 = CheckJsSxVoltage_CC(txtGDNo_b.Text, txtZxbz_b.Text.Trim(), strTmpClass, strTmpModel2, strTmpSize, strTmpVoltage, strTmpCapacity2, txtSNB_b.Text.Trim(), txtBz_b.Text.Trim());
                        if (str25UR1 == "2.5UR" || str25UR2 == "2.5UR")
                        {
                            strTmpMark += "        2.5UR";
                        }
                        else if (str25UR1 == "2UR" || str25UR2 == "2UR")
                        {
                            strTmpMark += "        2UR";
                        }
                        strTmpMark = strTmpMark.Trim();
                    }
                    dr["标志标识"] = strTmpMark.Trim ();
                    strTmpMark = string.Empty;
                    if (chkDPA_b.Checked)
                    {
                        strTmpMark += "        DPA合格";
                    }
                    if (chkFh_b.Checked)
                    {
                        strTmpMark += "        符合GJB4027A";
                    }
                    if (chkTcc_b.Checked)
                    {
                        strTmpMark += "        TCC测试";
                    }
                    dr["备注标识"] = strTmpMark.Trim();
                    dr["合同号"] = txtHth_b.Text.Trim();
                    dr["交货日期"] = txtJhrq_b.Text.Trim();
                    tmpdt.Rows.Add(dr);
                    break;
                case "C":
                    break;
            }
            return tmpdt;
        }

        private void iniComboBox()
        {
            cmbTemplates.Items.Clear();
            if (rbtnACard2 .Checked )
            {
                    cmbTemplates.Items.Add("MLCC生产流转卡A卡");
                    cmbTemplates.Items.Add("国军标片式MLCC生产流转卡A卡");
                    cmbTemplates.Items.Add("国军标引线MLCC生产流转卡A卡");
                    cmbTemplates.Items.Add("宇航级片式MLCC生产流转卡A卡");
                    cmbTemplates.Items.Add("宇航级引线MLCC生产流转卡A卡");
            }
            if (rbtnBCard2 .Checked )
            {
                    cmbTemplates.Items.Add("片式MLCC生产流转卡B卡");
                    cmbTemplates.Items.Add("引线MLCC生产流转卡B卡");
                    cmbTemplates.Items.Add("国军标片式MLCC生产流转卡B卡");
                    cmbTemplates.Items.Add("国军标引线MLCC生产流转卡B卡");
                    cmbTemplates.Items.Add("宇航级片式MLCC生产流转卡B卡");
                    cmbTemplates.Items.Add("宇航级引线MLCC生产流转卡B卡");
            }
            if (rbtnCCard2.Checked)
            {
                    cmbTemplates.Items.Add("引线MLCC生产流转卡C卡");
            }
        }

        private void txtSwdh_DoubleClick(object sender, EventArgs e)
        {
            frmSetSwdh newFrmSetSwdh = new frmSetSwdh();
            if (newFrmSetSwdh .ShowDialog ()==DialogResult.OK)
            {
                txtSwdh.Text = newFrmSetSwdh.strSelectedSwdh;
                txtNdjcwl.Text = newFrmSetSwdh.strSelectedNdjcwl;
            }
        }

        /// <summary>
        /// 检查是否符合2.5UR筛选条件
        /// </summary>
        /// <param name="strTmpGDNo">工单号</param>
        /// <param name="strTmpStandard">执行标准</param>
        /// <param name="strTmpClass">质量等级</param>
        /// <param name="strTmpModel">型号</param>
        /// <param name="strTmpSize">尺寸</param>
        /// <param name="strTmpVoltage">电压</param>
        /// <param name="strTmpCapacity">容量</param>
        /// <param name="strTmpSN">批号</param>
        /// <param name="strTmpMemo">备注</param>
        /// <returns>筛选电压信息（2.5UR/2UR/无）</returns>
        private string CheckJsSxVoltage(string strTmpGDNo,string strTmpStandard,string strTmpClass,string strTmpModel, string strTmpSize, string strTmpVoltage, string strTmpCapacity, string strTmpSN, string strTmpMemo)
        {
            try
            {
                //检查备注是否包含了2UR信息，如果有，则直接返回2UR
                if (strTmpMemo.Contains("2UR"))
                {
                    return "2UR";
                }
                //检查备注是否包含了2.5UR信息，如果有，则直接返回2.5UR
                if (strTmpMemo.Contains("2.5UR"))
                {
                    return "2.5UR";
                }
                //判断是否1608以后的批号，检查批号前四位是否大于等于1608，如果批号是1608之前的，则直接返回空
                if (!(GetDouble(strTmpSN.Substring(0, 4)) >= 1608))
                {
                    return string.Empty;
                }
                //判断是否复测（自检出库产品），通过检查工单号是否由出库单生成进行判断，如果是复测产品，则直接返回空
                string strCheckZjck = "select gxck001 from gxck_table where gxck028='@GDNo'";
                if (sqt.RecordExist(strCheckZjck.Replace("@GDNo", strTmpGDNo)))
                {
                    return string.Empty;
                }
                //判断是否片式产品，通过产品型号判断，如果不是片式产品，则直接返回空
                if (strTmpModel.Contains("4L") ||
                    strTmpModel.Contains("4H") ||
                    strTmpModel.Contains("CC411") ||
                    strTmpModel.Contains("C040") ||
                    strTmpModel.Contains("48L"))
                {
                    return string.Empty;
                }
                //判断执行标准是否完全匹配文件指定的标准，如果不能完全匹配，对比标准号，是否能模糊匹配
                bool bStandardChecked = false;          //标准是否确认，默认未确认
                if (strTmpStandard.Equals("LMS060101002-2017") ||
                    strTmpStandard.Equals("LMS060101003-2017") ||
                    strTmpStandard.Equals("LMS060101004-2017") ||
                    strTmpStandard.Equals("CASTPS02/029A-2017") ||
                    strTmpStandard.Equals("CASTPS02/030A-2017") ||
                    strTmpStandard.Equals("CASTPS02/031A-2017") ||
                    strTmpStandard.Equals("CASTPS02/061-2016") ||
                    strTmpStandard.Equals("SASTYPS0601/0001A-2017") ||
                    strTmpStandard.Equals("SASTYPS0601/0001B-2017") ||
                    strTmpStandard.Equals("SASTYPS0601/0002-2015") ||
                    strTmpStandard.Equals("SASTYPS0601/0003-2015") ||
                    strTmpStandard.Equals("Q/RQ140-2004") ||
                    strTmpStandard.Equals("Q/RQ140-2004+QZJ840624") ||
                    strTmpStandard.Equals("Q/RQ141-2004") ||
                    strTmpStandard.Equals("Q/RQ141-2004+QZJ840624") ||
                    strTmpStandard.Equals("Q/RQ142-2004") ||
                    strTmpStandard.Equals("Q/RQ142-2004+QZJ840624") ||
                    strTmpStandard.Equals("Q/RQ143-2004") ||
                    strTmpStandard.Equals("Q/RQ143-2004+QZJ840624") ||
                    strTmpStandard.Equals("Q/RQ140A-2014") ||
                    strTmpStandard.Equals("Q/RQ140A-2014+QZJ840624") ||
                    strTmpStandard.Equals("Q/RQ141A-2014") ||
                    strTmpStandard.Equals("Q/RQ141A-2014+QZJ840624") ||
                    strTmpStandard.Equals("Q/RQ142A-2014") ||
                    strTmpStandard.Equals("Q/RQ142A-2014+QZJ840624") ||
                    strTmpStandard.Equals("Q/RQ143A-2014") ||
                    strTmpStandard.Equals("Q/RQ143A-2014+QZJ840624") ||
                    strTmpStandard.Equals("Q/RQ26016A-2014") ||
                    strTmpStandard.Equals("Q/RQ26017A-2014") ||
                    strTmpStandard.Equals("Q/RQ26019A-2014"))
                {
                    //完全符合指定标准
                    bStandardChecked = true;
                }
                else if (strTmpStandard.Contains("060101002") ||
                            strTmpStandard.Contains("060101003") ||
                            strTmpStandard.Contains("060101004") ||
                            strTmpStandard.Contains("029A-2017") ||
                            strTmpStandard.Contains("030A-2017") ||
                            strTmpStandard.Contains("031A-2017") ||
                            strTmpStandard.Contains("061-2016") ||
                            strTmpStandard.Contains("0001A-2017") ||
                            strTmpStandard.Contains("0001B-2017") ||
                            strTmpStandard.Contains("0002-2015") ||
                            strTmpStandard.Contains("0003-2015") ||
                            strTmpStandard.Contains("140-2004") ||
                            strTmpStandard.Contains("141-2004") ||
                            strTmpStandard.Contains("142-2004") ||
                            strTmpStandard.Contains("143-2004") ||
                            strTmpStandard.Contains("140A-2014") ||
                            strTmpStandard.Contains("141A-2014") ||
                            strTmpStandard.Contains("142A-2014") ||
                            strTmpStandard.Contains("143A-2014") ||
                            strTmpStandard.Contains("26016A-2014") ||
                            strTmpStandard.Contains("26017A-2014") ||
                            strTmpStandard.Contains("26019A-2014"))
                {
                    //模糊匹配上，弹出提示要求人工确认
                    if (MessageBox.Show("当前执行标准 " + strTmpStandard + " 可能需要执行2.5UR加速筛选，请确认标准是否准确！", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.OK)
                    {
                        bStandardChecked = true;
                    }
                    else
                    {
                        return string.Empty;
                    }
                }
                else
                {
                    return string.Empty;
                }
                //检查等级和尺寸，如果等级是J，尺寸小于1812，则返回空，如果等级是空或M，则返回空
                if ((strTmpClass == "J" && GetInt(strTmpSize.Substring(0, 4)) < 1812)||
                    strTmpClass .Trim ().Equals (string.Empty )||
                    strTmpClass .Equals ("M"))
                {
                    return string.Empty;
                }
                //检查电压、容量是否满足文件指定要求
                double dVoltage = VoltageTranslate(strTmpVoltage);
                double dCapacity = CapactiyTranslate(strTmpCapacity);
                //高频产品
                if (strTmpModel.StartsWith("CC"))
                {
                    if (dVoltage == 25)
                    {
                        #region 高频25V
                        switch (strTmpSize)
                        {
                            case "0402":
                                if (dCapacity <= 470)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "0603":
                                if (dCapacity <= 2200)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "0805":
                            case "1":
                                if (dCapacity <= 10000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "1206":
                            case "1210":
                            case "2":
                                if (dCapacity <= 100000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "1812":
                            case "3a":
                                if (dCapacity <= 150000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "2220":
                            case "3b":
                                if (dCapacity <= 220000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "2225":
                            case "3c":
                            case "3035":
                            case "4":
                            case "4045":
                            case "5":
                                if (dCapacity <= 330000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "5868":
                            case "6":
                                if (dCapacity <= 680000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            default:
                                return String.Empty;
                        }
                        #endregion
                    }
                    else if (dVoltage == 50)
                    {
                        #region 高频50V
                        switch (strTmpSize)
                        {
                            case "0402":
                                if (dCapacity <= 470)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "0603":
                                if (dCapacity <= 1500)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "0805":
                            case "1":
                                if (dCapacity <= 6800)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "1206":
                                if (dCapacity <= 47000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "1210": 
                                if (dCapacity <= 68000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "1812":
                            case "3a":
                                if (dCapacity <= 100000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "2220":
                            case "3b":
                                if (dCapacity <= 150000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "2225":
                            case "3c":
                            case "3035":
                            case "4":
                            case "4045":
                            case "5":
                                if (dCapacity <= 220000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "5868":
                            case "6":
                                if (dCapacity <= 470000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            default:
                                return String.Empty;
                        }
                        #endregion
                    }
                    else if (dVoltage == 100)
                    {
                        #region 高频100V
                        switch (strTmpSize)
                        {
                            case "0402":
                                if (dCapacity <= 100)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "0603":
                                if (dCapacity <= 1000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "0805":
                            case "1":
                                if (dCapacity <= 3300)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "1206":
                                if (dCapacity <= 10000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "1210":
                                if (dCapacity <= 33000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "2":
                                if (dCapacity <= 10000 && dCapacity >= 1200 && dCapacity <= 8200)      //如容量在122到822之间，芯片是1206，按103判断
                                {
                                    return "2.5UR";
                                }
                                else if (dCapacity <= 33000 && dCapacity >= 9100 && dCapacity <= 18000)      //如容量在912到183之间，芯片是1210，按333判断
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "1812":
                            case "3a":
                                if (dCapacity <= 68000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "2220":
                            case "3b":
                                if (dCapacity <= 82000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "2225":
                            case "3c":
                            case "3035":
                            case "4":
                                if (dCapacity <= 100000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "4045":
                            case "5":
                                if (dCapacity <= 150000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                                break;
                            case "5868":
                            case "6":
                                if (dCapacity <= 330000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            default:
                                return String.Empty;
                        }
                        #endregion
                    }
                    else
                    {
                        return string.Empty ;
                    }
                }
                //低频产品
                else
                {
                    if (dVoltage == 6.3 || dVoltage == 10 || dVoltage == 16 || dVoltage == 25)
                    {
                        #region 低频6.3V/10V/16V/25V
                        switch (strTmpSize)
                        {
                            case "0402":
                                if (dCapacity <= 47000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "0603":
                                if (dCapacity <= 100000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "0805":
                            case "1":
                                if (dCapacity <= 150000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "1206":
                                if (dCapacity <= 330000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "1210": 
                                if (dCapacity <= 1000000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "1812":
                            case "3a":
                                if (dCapacity <= 1500000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "2220":
                            case "3b":
                                if (dCapacity <= 2200000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "2225":
                            case "3c":
                                if (dCapacity <= 3300000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "3035":
                            case "4":
                                if (dCapacity <= 4700000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "4045":
                            case "5":
                                if (dCapacity <= 10000000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "5868":
                            case "6":
                                if (dCapacity <= 15000000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            default:
                                return String.Empty;
                        }
                        #endregion
                    }
                    else if (dVoltage == 50)
                    {
                        #region 低频50V
                        switch (strTmpSize)
                        {
                            case "0402":
                                if (dCapacity <= 10000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "0603":
                                if (dCapacity <= 47000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "0805":
                            case "1":
                                if (dCapacity <= 100000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "1206":
                                if (dCapacity <= 220000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "1210": 
                                if (dCapacity <= 680000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "1812":
                            case "3a":
                                if (dCapacity <= 1000000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "2220":
                            case "3b":
                                if (dCapacity <= 1500000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "2225":
                            case "3c":
                                if (dCapacity <= 2200000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "3035":
                            case "4":
                                if (dCapacity <= 3300000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "4045":
                            case "5":
                                if (dCapacity <= 6800000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "5868":
                            case "6":
                                if (dCapacity <= 10000000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            default:
                                return String.Empty;
                        }
                        #endregion
                    }
                    else if (dVoltage == 100)
                    {
                        #region 低频100V
                        switch (strTmpSize)
                        {
                            case "0603":
                                if (dCapacity <= 15000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "0805":
                            case "1":
                                if (dCapacity <= 47000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "1206":
                                if (dCapacity <= 100000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "1210":
                                if (dCapacity <= 330000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "1812":
                            case "3a":
                                if (dCapacity <= 680000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "2220":
                            case "3b":
                                if (dCapacity <= 1000000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "2225":
                            case "3c":
                                if (dCapacity <= 1500000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "3035":
                            case "4":
                                if (dCapacity <= 2200000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "4045":
                            case "5":
                                if (dCapacity <= 3300000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "5868":
                            case "6":
                                if (dCapacity <= 4700000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            default:
                                return String.Empty;
                        }
                        #endregion
                    }
                    else
                    {
                        return String.Empty;
                    }
                }
                return String.Empty;
            }
            catch
            {
                return String.Empty;
            }
        }

        /// <summary>
        /// 检查是否符合2.5UR筛选条件(CASTPS02/029A-2017、CASTPS02/030A-2017、CASTPS02/031A-2017)
        /// </summary>
        /// <param name="strTmpGDNo">工单号</param>
        /// <param name="strTmpStandard">执行标准</param>
        /// <param name="strTmpClass">质量等级</param>
        /// <param name="strTmpModel">型号</param>
        /// <param name="strTmpSize">尺寸</param>
        /// <param name="strTmpVoltage">电压</param>
        /// <param name="strTmpCapacity">容量</param>
        /// <param name="strTmpSN">批号</param>
        /// <param name="strTmpMemo">备注</param>
        /// <returns>筛选电压信息（2.5UR/2UR/无）</returns>
        private string CheckJsSxVoltage_CC(string strTmpGDNo, string strTmpStandard, string strTmpClass, string strTmpModel, string strTmpSize, string strTmpVoltage, string strTmpCapacity, string strTmpSN, string strTmpMemo)
        {
            try
            {
                //检查备注是否包含了2UR信息，如果有，则直接返回2UR
                if (strTmpMemo.Contains("2UR"))
                {
                    return "2UR";
                }
                //检查备注是否包含了2.5UR信息，如果有，则直接返回2.5UR
                if (strTmpMemo.Contains("2.5UR"))
                {
                    return "2.5UR";
                }
                //判断是否复测（自检出库产品），通过检查工单号是否由出库单生成进行判断，如果是复测产品，则直接返回空
                string strCheckZjck = "select gxck001 from gxck_table where gxck028='@GDNo'";
                if (sqt.RecordExist(strCheckZjck.Replace("@GDNo", strTmpGDNo)))
                {
                    return string.Empty;
                }
                //判断执行标准是否完全匹配文件指定的标准，如果不能完全匹配，对比标准号，是否能模糊匹配
                bool bStandardChecked = false;          //标准是否确认，默认未确认
                if (strTmpStandard.Equals("CASTPS02/029A-2017") ||
                    strTmpStandard.Equals("CASTPS02/030A-2017") ||
                    strTmpStandard.Equals("CASTPS02/031A-2017"))
                {
                    //完全符合指定标准
                    bStandardChecked = true;
                }
                else if (strTmpStandard.Contains("CASTPS02/029A-2017") ||
                         strTmpStandard.Contains("CASTPS02/030A-2017") ||
                         strTmpStandard.Contains("CASTPS02/031A-2017"))
                {
                    //模糊匹配上，弹出提示要求人工确认
                    if (MessageBox.Show("当前执行标准 " + strTmpStandard + " 可能需要执行2.5UR加速筛选，请确认标准是否准确！", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.OK)
                    {
                        bStandardChecked = true;
                    }
                    else
                    {
                        return string.Empty;
                    }
                }
                else
                {
                    return string.Empty;
                }
                //检查电压、容量是否满足文件指定要求
                double dVoltage = VoltageTranslate(strTmpVoltage);
                double dCapacity = CapactiyTranslate(strTmpCapacity);
                //高频产品
                if (strTmpModel.StartsWith("CC"))
                {
                    if (dVoltage == 25)
                    {
                        #region 高频25V
                        switch (strTmpSize)
                        {
                            case "0603":
                                if (dCapacity <= 560)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "0805":
                                if (dCapacity <= 3300)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "1210":
                                if (dCapacity <= 15000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "1812":
                                if (dCapacity <= 22000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "2220":
                                if (dCapacity <= 47000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "2225":
                                if (dCapacity <= 100000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            default:
                                return String.Empty;
                        }
                        #endregion
                    }
                    else if (dVoltage == 50)
                    {
                        #region 高频50V
                        switch (strTmpSize)
                        {
                            case "0603":
                                if (dCapacity <= 470)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "0805":
                            case "1":
                                if (dCapacity <= 2200)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "1210":
                            case "2":
                                if (dCapacity <= 10000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "1812":
                            case "3a":
                            case "2220":
                            case "3b":
                                if (dCapacity <= 47000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "2225":
                            case "3c":
                                if (dCapacity <= 68000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "4":
                                if (dCapacity <= 100000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "5":
                                if (dCapacity <= 220000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "6":
                                if (dCapacity <= 470000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            default:
                                return String.Empty;
                        }
                        #endregion
                    }
                    else if (dVoltage == 100)
                    {
                        #region 高频100V
                        switch (strTmpSize)
                        {
                            case "0603":
                                if (dCapacity <= 270)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "0805":
                            case "1":
                                if (dCapacity <= 1000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "1210":
                            case "2":
                                if (dCapacity <= 6800)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "1812":
                            case "3a":
                            case "2220":
                            case "3b":
                                if (dCapacity <= 33000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "2225":
                            case "3c":
                            case "4":
                                if (dCapacity <= 47000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "5":
                                if (dCapacity <= 100000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                                break;
                            case "6":
                                if (dCapacity <= 330000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            default:
                                return String.Empty;
                        }
                        #endregion
                    }
                    else
                    {
                        return string.Empty;
                    }
                }
                //低频产品
                else
                {
                    if (dVoltage == 16 || dVoltage == 25)
                    {
                        #region 低频16V/25V
                        switch (strTmpSize)
                        {
                            case "0402":
                                if (dCapacity <= 4700)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "0603":
                                if (dCapacity <= 47000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "0805":
                                if (dCapacity <= 150000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "1210":
                                if (dCapacity <= 1000000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "1812":
                            case "2220":
                            case "2225":
                                if (dCapacity <= 680000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "3035":
                                if (dCapacity <= 4700000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            default:
                                return String.Empty;
                        }
                        #endregion
                    }
                    else if (dVoltage == 50)
                    {
                        #region 低频50V
                        switch (strTmpSize)
                        {
                            case "0603":
                                if (dCapacity <= 15000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "0805":
                            case "1":
                                if (dCapacity <= 100000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "1210":
                            case "2":
                                if (dCapacity <= 680000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "1812":
                            case "3a":
                            case "2220":
                            case "3b":
                            case "2225":
                            case "3c":
                                if (dCapacity <= 680000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "3035":
                            case "4":
                                if (dCapacity <= 3300000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "5":
                                if (dCapacity <= 6800000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            default:
                                return String.Empty;
                        }
                        #endregion
                    }
                    else if (dVoltage == 100)
                    {
                        #region 低频100V
                        switch (strTmpSize)
                        {
                            case "0603":
                                if (dCapacity <= 10000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "0805":
                            case "1":
                                if (dCapacity <= 47000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "1210":
                            case "2":
                                if (dCapacity <= 330000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "1812":
                            case "3a":
                                if (dCapacity <= 680000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "2220":
                            case "3b":
                            case "2225":
                            case "3c":
                                if (dCapacity <= 470000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "3035":
                            case "4":
                                if (dCapacity <= 2200000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            case "5":
                                if (dCapacity <= 3300000)
                                {
                                    return "2.5UR";
                                }
                                else
                                {
                                    return String.Empty;
                                }
                                break;
                            default:
                                return String.Empty;
                        }
                        #endregion
                    }
                    else
                    {
                        return String.Empty;
                    }
                }
                return String.Empty;
            }
            catch
            {
                return String.Empty;
            }
        }
        #endregion


    }
}
